<template>
  <div>
    <el-tabs type="border-card" @tab-click="tabsEvent" v-model="currentName">
      <playerInfo :pId="pId" @playerCoachMapReload="playerCoachMapReload" @personChange="personChange" />
      <el-tab-pane name="0" label="执教教练"><keep-alive><playerCoachMap v-if="index == 0" ref="playerCoachMap" :pId="pId" :newPerson="this.$route.params.newPerson" /></keep-alive></el-tab-pane>
      <el-tab-pane name="1" label="基本信息"><keep-alive><playerDetail v-if="index == 1" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="2" label="入队信息"><keep-alive><playerTeam v-if="index == 2" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="3" label="家庭成员"><keep-alive><playerFamily v-if="index == 3" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="4" label="教育经历"><keep-alive><playerEducation v-if="index == 4" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="5" label="学籍情况"><keep-alive><playerSchoolRoll v-if="index == 5" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="6" label="运动等级"><keep-alive><playerProfessionLevel v-if="index == 6" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="7" label="走向输送"><keep-alive><playerTransport v-if="index == 7" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="8" label="上级单位集训试训"><keep-alive><playerTraining v-if="index == 8" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="9" label="运动简历"><keep-alive><playerSportResume v-if="index == 9" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="10" label="奖惩情况"><keep-alive><playerRewardPunishment v-if="index == 10" :pId="pId" /></keep-alive></el-tab-pane>
      <el-tab-pane name="11" label="比赛成绩"><keep-alive><matchResult v-if="index == 11" :pId="pId" /></keep-alive></el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
  import playerInfo from '@/components/person/playerDetail/playerInfo.vue'
  import playerCoachMap from '@/components/person/playerDetail/playerCoachMap.vue'
  import playerDetail from '@/components/person/playerDetail/playerDetail.vue'
  import playerTeam from '@/components/person/playerDetail/playerTeam.vue'
  import playerFamily from '@/components/person/playerDetail/playerFamily.vue'
  import playerEducation from '@/components/person/playerDetail/playerEducation.vue'
  import playerSchoolRoll from '@/components/person/playerDetail/playerSchoolRoll.vue'
  import playerProfessionLevel from '@/components/person/playerDetail/playerProfessionLevel.vue'
  import playerTransport from '@/components/person/playerDetail/playerTransport.vue'
  import playerTraining from '@/components/person/playerDetail/playerTraining.vue'
  import playerSportResume from '@/components/person/playerDetail/playerSportResume.vue'
  import playerRewardPunishment from '@/components/person/playerDetail/playerRewardPunishment.vue'
  import matchResult from '@/components/person/playerDetail/matchResult.vue'
  export default {
    components: {
      playerInfo,
      playerCoachMap,
      playerDetail,
      playerTeam,
      playerFamily,
      playerEducation,
      playerSchoolRoll,
      playerProfessionLevel,
      playerTransport,
      playerTraining,
      playerSportResume,
      playerRewardPunishment,
      matchResult,
    },
    inject: ['reload'],
    data() {
      return {
        pId: '',
        index: 0,
        currentName: '0',
      }
    },
    created() {
      this.pId = window.sessionStorage.getItem('pId')
      let currentNameIndex = window.sessionStorage.getItem('detailIndex')
      if(currentNameIndex){
        this.index = this.currentName = JSON.parse(currentNameIndex)+''
      }
    },
    methods:{
      personChange(pid) {
        window.sessionStorage.setItem('pId',pid)
        this.pId = pid
        this.reload()
      },
      playerCoachMapReload() {
        this.$refs.playerCoachMap.playerCoachMapReload()
      },
      tabsEvent(e){
        this.index = e.index
        this.currentName = e.index+''
        window.sessionStorage.setItem('detailIndex',this.currentName)
      },
    },
    destroyed() {
      // window.localStorage.removeItem('pId')
    },
  }
</script>

<style lang="scss" scoped>

</style>
